package com.example.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DemoTest {

    public static void main(String[] args) {

        //日期  比如今天8月1日  加一个月
     /*   Date date = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);   //设置当前时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(format.format(cal.getTime()));

         cal.add(Calendar.MONTH, 1);
        System.out.println(format.format(cal.getTime()));

*/
        Calendar dd = Calendar.getInstance();//定义日期实例
        Date date = new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);   //设置当前时间
        cal.add(Calendar.MONTH, 1);
        Date d2 = cal.getTime();
        List<Integer> list = new ArrayList<Integer>();
        while (dd.getTime().before(d2)) {//判断是否到结束日期
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String str = sdf.format(dd.getTime());
            System.out.println("日期" + str);//输出日期结果
            String substring = str.substring(8, 10);
            int num = 0;
            if (substring.startsWith("0")) {
                num = Integer.parseInt(substring);
                System.out.println("qiege日期" + num);
            } else {
                num = Integer.valueOf(substring).intValue();
            }
            list.add(num);
            dd.add(Calendar.DATE, 1);//进行当前日期月份加1
        }

        for (int i = 0; i < list.size(); i++) {
            Integer integer = list.get(i);
            //2 是组数
            String one = "第一组";
            String two = "第二组";
            String three = "第三组";
            String four = "第四组";
            int yushu = integer % 4;
            System.out.println("余数" + yushu);
            if (0 == yushu) {
                System.out.println(one + "今天是 " + integer + "号");
            } else if (1 == yushu)  {
                System.out.println(two + "今天是 " + integer + "号");
            }else if (2 == yushu){
                System.out.println(three + "今天是 " + integer + "号");
            }else {
                System.out.println(four + "今天是 " + integer + "号");
            }
        }

    }
}
